package com.gitee.oeoe.hot.refresh;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;

import java.nio.file.Path;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 热更新 bean
 *
 * @author oeoe
 * @since jdk1.8+ 2023/1/7
 */
@Slf4j
public class HotRefresh {
    private static final ExecutorService EXECUTORSERVICE = Executors.newCachedThreadPool();

    public HotRefresh(SqlSessionFactory sqlSessionFactory, Path path) {
        Configuration configuration = sqlSessionFactory.getConfiguration();
        RefreshTask refreshTask = new RefreshTask(configuration, path);
        EXECUTORSERVICE.submit(refreshTask);
    }

}
